import React, { Component } from 'react'

export default class componentName extends Component {
  state = {
    count: 8,
  }
  handleClick = () => {
    /* this.setState(
      {
        count: this.state.count + 1,
      },
      () => {
        // 这儿可以拿到更新之后的数据
        console.log(this.state.count)
      }
    ) */
    this.setState({
      count: this.state.count + 1,
    })
  }
  render() {
    return (
      <div>
        <p>{this.state.count}</p>
        <button onClick={this.handleClick}>+1</button>
      </div>
    )
  }
  /* componentDidMount() {
    this.setState({ count: 99 }, () => {
      console.log(this.state.count)
    })
  } */
  componentDidUpdate() {
    console.log(this.state.count)
  }
}
